#!/bin/bash
apt -y install bind9 dnsutils
mkdir -p /etc/bind/k8s.lcom/ #dns配置文件文件夹子
echo 'include "/etc/bind/k8s.lcom/k8s.lcom.zones";' >> /etc/bind/named.conf

##配置zones文件
cat << EOF > /etc/bind/k8s.lcom/k8s.lcom.zones
zone "k8s.lcom" IN {
    type master;
    file "/etc/bind/k8s.lcom/k8s.lcom";
    allow-update { localhost ;};
};
EOF

##配置正向查询文件
cat << EOF > /etc/bind/k8s.lcom/k8s.lcom;
\$TTL 8D
@ IN SOA @ k8s.lcom. (
        2020062101
        1D
        1H
        1W
        3H )
 
    NS @
    A   192.168.1.103
dns A   192.168.1.103
ntp A   192.168.1.103
EOF
chgrp  -R bind /etc/bind/k8s.lcom
systemctl restart bind9
systemctl enable bind9
